﻿/*
 * Created by SharpDevelop.
 * User: cszhangyi
 * Date: 2016/4/9
 * Time: 14:58
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Net;
using System.Text;
using System.IO;
using System.IO.Compression;

namespace YMTSeller
{
	/// <summary>
	/// Description of YMTResponse.
	/// </summary>
	public class YMTResponse
	{
		public YMTResponse()
		{
		}
		
		public string getResponse(HttpWebResponse response)
		{
			string ret = string.Empty;
			
			Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
			string isZip = response.ContentEncoding;
			StreamReader sr;
			
			if (isZip.Equals("gzip"))
                	sr = new StreamReader(new GZipStream(response.GetResponseStream(), CompressionMode.Decompress), encode);
                else
                	sr = new StreamReader(response.GetResponseStream(), encode);
                
            ret = sr.ReadToEnd();
            sr.Close();
            response.Close();
            
            return ret;
		}
	}
}
